<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/1
 * Time: 9:30
 */

namespace app\api\service;


use app\common\model\Users;

class AfterSale
{
    static function save_(\app\common\model\Order $order, $memo)
    {
        $re_ = \app\common\model\AfterSale::create([
            "order_id" => $order->order_id,
            "user_id" => $order->user_id,
            "user_name" => $order->user_name,
            "telephone" => $order->telephone,
            "community_id" => $order->community_id,
            "address" => $order->address,
            "seller_id" => $order->seller_id,
            "memo" => $memo
        ]);
        return $re_;
    }

    static function list_(Users $user)
    {
        $obj = new \app\common\model\AfterSale();
        $re_ = $obj->where([
            "user_id" => $user->user_id,
        ])->paginate();
        return $re_;
    }

    static function by_order(\app\common\model\Order $order)
    {
        $obj = new \app\common\model\AfterSale();
        $re_ = $obj->where([
            "order_id" => $order->order_id,
        ])->find();
        return $re_;
    }
}